#pragma once

#include <iostream>
#include <vector>
#include "Define.h"
#include "SkillInfo.h"
#include "Item.h"

using namespace std;

namespace Next
{
	namespace GameServer
	{
		using namespace Skill;
		using namespace Items;

		namespace Objects
		{
			using namespace Defines;

			class CMuObject
			{
			private:

				/**
				* Fields
				**/
				unsigned short		uIndex;
				MuConnectionType	cConnected;
				MuObjectType		cType;
				bool				bLive;

				unsigned char		uClass;
				char				szName[MAX_NAME_SIZE+1];

				short				sX;
				short				sY;
				short				sTX;
				short				sTY;
				short				sMTX;
				short				sMTY;
				unsigned short		uStartX;
				unsigned short		uStartY;
				char				sDirection;

				unsigned char		uMapNumber;

				ObjectState			cState;

				unsigned char		uViewState;
				unsigned char		uViewSkillState;

				unsigned long		uLastAttackTime;
				unsigned long		uPacketCheckTime;

				unsigned long		uTeleportTime;
				bool				bTeleport;
				unsigned char		uDieRegen;
				KillerType			cKillerType;
				unsigned char		uRegenOk;
				unsigned char		uRegenMapNumber;
				unsigned char		uRegenMapX, uRegenMapY;
				unsigned long		uRegenTime;
				unsigned long		uMaxRegenTime;

				unsigned long		uDelayActionTime;
				unsigned char		uDelayLevel;

				unsigned char		uPoisonBeattackCount;
				unsigned char		uColdBeattackCount;

				CMuObject*			cAttackObj;

				signed int			sSkillNumber;
				unsigned long		uSkillTime;

				unsigned short		uTargetNumber;

				unsigned int		uAttackDamageLeft;
				unsigned int		uAttackDamageRight;
				unsigned int		uAttackDamageMaxLeft;
				unsigned int		uAttackDamageMinLeft;
				unsigned int		uAttackDamageMaxRight;
				unsigned int		uAttackDamageMinRight;
				unsigned int		uAttackSpeed;
				unsigned int		uAttackDamageMin;
				unsigned int		uAttackDamageMax;
				unsigned int		uDefense;
				unsigned int		uAttackRating;
				unsigned int		uSuccessfulBlocking;
				unsigned int		uMoveSpeed;

				CSkillInfo*			cSkillBack;
				CSkillInfo*			cSkill;
				unsigned char		uSkillCount;
				unsigned char		uUseSkillNumber;
				unsigned long		uUseSkillTime;
				unsigned char		uUseSkillCount;

				unsigned char		uResistance[MAX_RESISTANCE];

				unsigned int		uPathCount;

				typedef struct {
					signed int X, Y;
				}					stFrustrum[MAX_FRUSTRUM];

				vector<VIEWPORT_STRUCT*>		vecVpPlayer;
				vector<VIEWPORT_PLAYER_STRUCT*> vecVpPlayer2;
				unsigned int		uVpCount;
				unsigned int		uVpCount2;

				CItem*				cInventory;
				unsigned char*		upInventoryMap;
				unsigned char*		upInventoryCount;
				unsigned char		uTransaction;

				CItem*				cInventory1;
				unsigned char*		upInventoryMap1;
				unsigned char*		upInventoryCount1;
				
				CItem*				cInventory2;
				unsigned char*		upInventoryMap2;
				unsigned char*		upInventoryCount2;

			private:
				virtual void Init();

			public://functions
				CMuObject();
				~CMuObject();

			public://gets
				__forceinline unsigned short Index() { return uIndex; }
				__forceinline MuConnectionType Connected() { return cConnected; }
				__forceinline MuObjectType Type() { return cType; }
				__forceinline bool IsLive() { return bLive; }
				__forceinline unsigned char Class() { return uClass; }
				__forceinline char* Name() { return szName; }
				__forceinline short X() { return sX; }
				__forceinline short Y() { return sY; }
				__forceinline short TX() { return sTX; }
				__forceinline short TY() { return sTY; }
				__forceinline short MTX() { return sMTX; }
				__forceinline short MTY() { return sMTY; }
				__forceinline unsigned short StartX() { return uStartX; }
				__forceinline unsigned short StartY() { return uStartY; }
				__forceinline char Dir() { return sDirection; }
				__forceinline unsigned char MapNumber() { return uMapNumber; }

				__forceinline CItem* Inventory2() { return cInventory2; }
				__forceinline unsigned char* InvenrotyMap2() { return upInventoryMap2; }
				__forceinline unsigned char* InventoryCount2() { return upInventoryCount2; }

			public://sets
				__forceinline void SetIndex(unsigned short index) { uIndex = index; };
				__forceinline void SetType(MuObjectType type) { cType = type; };
				__forceinline void SetName(char* name) { strcpy_s(szName, name); };

			};

			class CMuMonster : public CMuObject
			{
			private:

				unsigned char				uRest;

				unsigned short				uPosNum;

				unsigned long				uCurActionTime;
				unsigned long				uNextActionTime;
				unsigned int				uRecallMon;

				signed short				sMoveRange;
				signed short				sAttackRange;
				signed short				sAttackType;
				signed short				sViewRange;
				signed short				sAttribute;
				signed short				sItemRate;
				signed short				sMoneyRate;

				unsigned int				uPathCur;
				unsigned long				uPathTime;
				vector<HITDAMAGE_STRUCT*>	vecHitDamage;


			public:
				CMuMonster(){};
				~CMuMonster(){};
			};

			class CMuNpc : public CMuObject
			{
			private:
				unsigned short	uShopNumber;

			public:
				CMuNpc(){};
				~CMuNpc(){};
			};
		}
	}
}
